{include file="public/header" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="ibox-content">

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">问题：</label>
                                    <div class="col-sm-9">
                                        <input name="title" type="text" class="form-control" value="{present name='name'}{$name.title}{/present}">
                                    </div>
                                </div>
                                <div id="select">
                                    {volist name="content" id="vo" key="k"}
                                    <div class="form-group" id="option{$k}">
                                        <label class="col-sm-2 control-label">选项：</label>
                                        <div class="col-sm-3">
                                            <input name="content[]" type="text" class="form-control" value="{$vo}">
                                        </div>
                                        <div class="col-sm-2">
                                            <div class="btn btn-danger" onclick="deloption('{$k}')">删除选项</div>
                                        </div>
                                    </div>
                                    {/volist}
                                    {empty name="content"}
                                    <div class="form-group" id="option0">
                                        <label class="col-sm-2 control-label">选项：</label>
                                        <div class="col-sm-3">
                                            <input name="content[]" type="text" class="form-control" value="">
                                        </div>
                                        <div class="col-sm-2">
                                            <div class="btn btn-danger" onclick="deloption('0')">删除选项</div>
                                        </div>
                                    </div>
                                    {/empty}
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-9">
                                        <div class="btn btn-primary" onclick="addoption()">添加选项</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

    $(document).ready(function(){
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        })

    });

    function addoption(){
        let time = new Date() / 1000 * 1000
        let tmp = `
                <div class="form-group" id="option${time}">
                    <label class="col-sm-2 control-label">选项：</label>
                    <div class="col-sm-3">
                        <input name="content[]" type="text" class="form-control" value="">
                    </div>
                    <div class="col-sm-2">
                        <div class="btn btn-danger" onclick="deloption(${time})">删除选项</div>
                    </div>
                </div>`
        $('#select').append(tmp)
    }

    function deloption(id){
        $('#option' + id).remove()
    }
</script>
{include file="public/bottom" /}